//
//  MPlusLogin.m
//  medicineplus
//
//  Created by gufei on 15-4-13.
//  Copyright (c) 2015年 chn_ruby@126.cn. All rights reserved.
//

#import "MPlusLogin.h"
#import "MPlusDefine.h"
#import "NSString+MD5.h"

@implementation MPlusLogin

NSString *_username;
NSString *_password;

- (id)initWithUsername:(NSString *)username password:(NSString *)password {
    self = [super init];
    if (self) {
        _username = username;
        _password = password;
    }
    return self;
}

- (NSString *)requestUrl {
    // 前缀在YTKNetworkConfig中设置，这里只填除去域名剩余的网址信息
    return kCMDLoginURL;
}

- (YTKRequestMethod)requestMethod {
    // 通过覆盖 YTKRequest 类的 `requestMethod`方法，实现了指定 POST 方法来传递参数。
    return YTKRequestMethodPost;
}

- (id)requestArgument {
    NSString *md5Str = [[[[[[_username stringByAppendingString:@"$"]
                         stringByAppendingString:@"123"] stringByAppendingString:@"$"]
                         stringByAppendingString:@"123456"] stringByAppendingString:@"$"]
                         stringByAppendingString:@"123456"];
    NSString *sign = [NSString md5:md5Str];
    // 通过覆盖 YTKRequest 类的 `requestArgument`方法，提供了 POST 的信息。
    return @{
             kJMobile:   _username,
             kJPassWord: _password,
             kJPlatform: @"2",
             kJToken:    @"123",
             kJTimes:    @"123456",
             kJSign:     sign
             };
}



@end
